﻿
using SailHero.Soft.FrameWork.DomainRepositories;
using SailHero.Soft.FrameWork.Models;

namespace UI.Web.SL.Demo.RIAServices.Web
{
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.ComponentModel.DataAnnotations;
    using System.Linq;
    using System.ServiceModel.DomainServices.Hosting;
    using System.ServiceModel.DomainServices.Server;


    // TODO: Create methods containing your application logic.
    [EnableClientAccess()]
    public class CustomerDService : DomainService
    {
        private CustomerRepository _bllCustomer = new CustomerRepository();
        public void Add(CUSTOMER customer)
        {
            customer.ID = Guid.NewGuid().ToString("N");
            _bllCustomer.Add(customer);
            _bllCustomer.UnitOfWork.SaveChanges();
        }

        [Delete]
        public void Delete(CUSTOMER customer)
        {
            _bllCustomer.Delete(customer);
            _bllCustomer.UnitOfWork.SaveChanges();
        }

        [Query]
        public List<CUSTOMER> GetCustomers()
        {
            return _bllCustomer.GetCustomers();
        }
    }
}


